import { GOODS_PENDING, GOODS_RESOLVE, GOODS_REJECT } from './../constants/goods';
import { MENUS_PENDING, MENUS_RESOLVE, MENUS_REJECT } from './../constants/menus';
import { URL_FIND_MENUS } from './../constants/SystemConstants';
import { WXRequest } from './../utils/WXRequest';

export const checkMenus = (id) => async dispatch => {
  dispatch({
    type: GOODS_PENDING
  })
  WXRequest(URL_FIND_MENUS, 'GET', {id: id}).then(res => {
    dispatch({
      type: GOODS_RESOLVE,
      goods: res.data[0]
    })
  }).catch(e => {
    console.error(e)
    dispatch({
      type: GOODS_REJECT
    })
  })
}